/**
 * 
 */
package com.gite.nouette.admin.implementation.model;

import com.gite.nouette.admin.contract.model.IModel;

/**
 * @author Cyril
 * 
 */
public abstract class AbstractModel implements IModel {
	private int id = 0;
	private String name = null;

	/**
	 * @return the id
	 */
	@Override
	public int getId() {
		return this.id;
	}

	/**
	 * @param id
	 *            the id to set
	 */
	@Override
	public void setId(int id) {
		this.id = id;
	}

	/**
	 * @return the name
	 */
	@Override
	public String getName() {
		return this.name;
	}

	/**
	 * @param name
	 *            the name to set
	 */
	@Override
	public void setName(String name) {
		this.name = name;
	}

	@Override
	public int hashCode() {
		final int prime = 31;
		int result = 1;
		result = prime * result + this.id;
		return result;
	}

	@Override
	public boolean equals(Object obj) {
		if (this == obj)
			return true;
		if (obj == null)
			return false;
		if (getClass() != obj.getClass())
			return false;
		AbstractModel other = (AbstractModel) obj;
		if (this.id != other.id)
			return false;
		return true;
	}

	@Override
	public int compareTo(IModel model) {
		if (model != null) {
			return getId() - model.getId();
		}
		return 1;
	}
}
